<?php
/* @var $list array(new Purchase) */
?>
<div style="margin-top:20px;color:#666">
    <?php
    if (isset($list)) {
        echo '<h3>Last Purchases of ' . $name . '</h3>';
		
        echo '<table class="cmn_table"><tr><th width="30%">Date</th><th  width="20%">Quantity</th><th  width="20%">Price</th><th>By</th></tr>';
        foreach ($list as $value) {
            echo '<tr>';
            echo '<td>';
            echo date('jS  F Y h:i:s a', strtotime($value->date_at));
            echo '</td>';
            echo '<td>';
            echo $value->quantity;
            echo '</td>';
            echo '<td>';
            echo $value->amout;
            echo '</td>';
            echo '<td>';
            if (isset($value->by)) {
                echo $value->by->profile->name;
            } else {
                echo '-';
            }
            echo '</td>';
            echo '</tr>';
        }
        echo '</table>';
    }
    ?>
</div>